import os

import numpy as np
import cv2
from scipy.constants import point

if __name__ == '__main__':
    img_path = r'./data/test/images'
    img_names = os.listdir(img_path)
    cls = 0  # 汽车车牌类别

    for file in img_names:
        img = cv2.imread(os.path.join(img_path, file))
        H,W = img.shape[:2]

        label = np.loadtxt(r'./output.txt', dtype=np.float32)
        box = label[1:5]
        box[:2] -= box[2:]/2
        box[2:] = box[2:]+box[:2]
        box = box.reshape(2,2)
        box[:,0] *= W
        box[:,1] *= H
        box = box.astype(np.int32)
        points = label[5:].reshape(4,2)
        points[:,0] *= W
        points[:,1] *= H
        points = points.astype(np.int32)

        for pt in box:
            cv2.circle(img, pt, 5,(0,0,255), 3)
        for pt in points:
            cv2.circle(img, pt, 3,(0,255,0), -1)

        cv2.imshow('test', img)
        cv2.waitKey(0)


        break